package com.buct.coder.core.handler;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Description:
 * @Auther: xinzi
 * @Date: 2022/08/28/12:49
 */
@MappedTypes({List.class})
@MappedJdbcTypes(JdbcType.VARCHAR)
public class ListTypeHandler extends FastjsonTypeHandler {

    public ListTypeHandler(Class<?> type) {
        super(type);
    }

    @Override
    protected List<?> parse(String json) {
        return JSON.parseArray(json, Long.class);
    }

    @Override
    protected String toJson(Object obj) {
        return super.toJson(obj);
    }

}